<template>
  <div class="home-container">
    <el-row :gutter="20">
      <el-col :span="24">
        <el-card class="welcome-card">
          <template #header>
            <div class="card-header">
              <h2>欢迎使用 ERAT 实验报告分析工具</h2>
            </div>
          </template>
          <div class="card-content">
            <p>ERAT (Experiment Report Analysis Tool) 是一个用于统计和分析实验报告提交情况的工具，可以帮助教师快速了解学生的实验报告提交情况。</p>
            <p>本工具采用 Attribute-Driven Development (ADD) 软件设计方法，实现了分层架构和多种设计模式，提供了高可维护性和可扩展性。</p>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <el-row :gutter="20" class="feature-row">
      <el-col :span="8">
        <el-card class="feature-card">
          <template #header>
            <div class="card-header">
              <h3>班级与课程管理</h3>
            </div>
          </template>
          <div class="card-content">
            <el-icon class="feature-icon"><School /></el-icon>
            <p>管理班级和课程信息，支持从Excel导入学生名单，手动添加/删除学生信息。</p>
            <div class="feature-actions">
              <el-button type="primary" @click="navigateTo('/class/list')">班级管理</el-button>
              <el-button type="success" @click="navigateTo('/course/list')">课程管理</el-button>
            </div>
          </div>
        </el-card>
      </el-col>
      
      <el-col :span="8">
        <el-card class="feature-card">
          <template #header>
            <div class="card-header">
              <h3>实验报告统计</h3>
            </div>
          </template>
          <div class="card-content">
            <el-icon class="feature-icon"><Document /></el-icon>
            <p>按照实验维度和学生维度统计实验报告提交情况，生成缺交名单和缺交实验列表。</p>
            <div class="feature-actions">
              <el-button type="primary" @click="navigateTo('/report/experiment')">实验维度统计</el-button>
              <el-button type="success" @click="navigateTo('/report/student')">学生维度统计</el-button>
            </div>
          </div>
        </el-card>
      </el-col>
      
      <el-col :span="8">
        <el-card class="feature-card">
          <template #header>
            <div class="card-header">
              <h3>可视化分析</h3>
            </div>
          </template>
          <div class="card-content">
            <el-icon class="feature-icon"><TrendCharts /></el-icon>
            <p>通过折线图直观展示实验报告提交率，支持导出统计结果为Excel或CSV文件。</p>
            <div class="feature-actions">
              <el-button type="primary" @click="navigateTo('/report/visualization')">查看分析图表</el-button>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <el-col :span="24">
        <el-card class="info-card">
          <template #header>
            <div class="card-header">
              <h3>系统架构与设计模式</h3>
            </div>
          </template>
          <div class="card-content">
            <p><strong>架构设计：</strong>采用分层架构（表现层、业务逻辑层、数据访问层），提高系统的可维护性和可测试性。</p>
            <p><strong>设计模式应用：</strong></p>
            <ul>
              <li><strong>工厂模式：</strong>用于动态创建不同格式的文件解析器（Excel/CSV）。</li>
              <li><strong>组合模式：</strong>用于实现对实验报告的分类统计。</li>
              <li><strong>单例模式：</strong>用于日志记录器，确保全局唯一实例。</li>
            </ul>
            <p><strong>异常处理与日志：</strong>对文件读取、文件名解析等操作进行异常提示，记录关键操作日志。</p>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { useRouter } from 'vue-router'
import { School, Document, TrendCharts } from '@element-plus/icons-vue'

export default {
  name: 'HomeView',
  components: {
    School,
    Document,
    TrendCharts
  },
  setup() {
    const router = useRouter()

    const navigateTo = (path) => {
      router.push(path)
    }

    return {
      navigateTo
    }
  }
}
</script>

<style scoped>
.home-container {
  max-width: 1200px;
  margin: 0 auto;
}

.welcome-card {
  margin-bottom: 20px;
}

.feature-row {
  margin-bottom: 20px;
}

.feature-card {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h2, .card-header h3 {
  margin: 0;
  color: #303133;
}

.card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.feature-icon {
  font-size: 48px;
  color: #409EFF;
  margin-bottom: 15px;
  align-self: center;
}

.feature-actions {
  margin-top: auto;
  display: flex;
  justify-content: space-around;
  padding-top: 15px;
}

.info-card ul {
  padding-left: 20px;
}

.info-card li {
  margin-bottom: 8px;
}
</style>
